package org.dbstar.scheduler.actions;

import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.dbstar.scheduler.beans.OperateType;
import org.dbstar.scheduler.control.JobConfController;
import org.dbstar.scheduler.identifier.Identifier;
import org.dbstar.scheduler.identifier.IdentifierType;


/**
 * 通过Ajax来获取一些实体bean的json数据
 * 
 * @author 代波
 * @since 1.0.0
 * @version 1.0.0
 * @date 2012-5-4
 */
@ParentPackage("json-default")
@Results({ @Result(name = "success", type = "json") })
public class AjaxAction extends ActionSupport {
	// 仅接收
	private Identifier identifier;
	private JobConfController jobConfController;

	// 仅传出
	private Object obj;

	public void setIdentifier(Identifier identifier) {
		this.identifier = identifier;
	}

	public void setJobConfController(JobConfController jobConfController) {
		this.jobConfController = jobConfController;
	}

	public Object getObj() {
		return obj;
	}

	@Override
	public String execute() throws Exception {
		if (identifier != null) {
			if (IdentifierType.conf == identifier.getIdentifierType()) {
				this.obj = jobConfController.getJobConf(identifier);
				operate(OperateType.ajax_conf, identifier);
			}
		}
		return SUCCESS;
	}
}
